home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / COMMUNIC / 0576.ZIP / STAYI16.410 < prev    next >
Text File  |  1986-06-13  |  7KB  |  99 lines

  1. Inline(
  2.                               {;****************************************************************************;}
  3.                               {;                 P R O C E S S    I N T E R R U P T   1 6                   ;}
  4.                               {;                                                                            ;}
  5.                               {;****************************************************************************;}
  6.                               {; Function:}
  7.                               {;          Provide a Keyboard trap to allow concurrent processes to}
  8.                               {;          run in the background while a Turbo Read is active.}
  9.                               {;}
  10.                               {; Copyright (C) 1985,1986}
  11.                               {;                    Lane Ferris}
  12.                               {;              - The Hunter's Helper -}
  13.                               {;       Distributed to the Public Domain for use without profit.}
  14.                               {;              Original Version 5.15.85}
  15.                               {;}
  16.                               {;           ; On entry the Stack will already contain: ;}
  17.                               {;           ;  1) Sp for Dos                           ;}
  18.                               {;           ;  2) Bp for Dos                           ;}
  19.                               {;           ;  3) Ip for Dos                           ;}
  20.                               {;           ;  4) Cs for Dos                           ;}
  21.                               {;           ;  5) Flags for Dos                        ;}
  22.   $5D                         {        Pop     Bp}
  23.   /$5D                        {        Pop     Bp              ; Restore Original Bp}
  24.   /$80/$FC/$00                {        Cmp     Ah,00           ; If Char request,}
  25.   /$74/$2A                    {        Je      Func00          ;  loop for character}
  26.   /$80/$FC/$01                {        Cmp     Ah,01           ; If character availability test}
  27.   /$74/$05                    {        Je      Func01          ;   go check for char}
  28.                               {GoBios16:}
  29.   /$2E                        {        CS:                     ; Go to Bios Interrupt 16}
  30.   /$FF/$2E/>BIOS_INT16        {        Jmp Far [>BIOS_Int16]}
  31.                               {Func01:}
  32.   /$E8/$3F/$00                {        Call    KeyStat         ; Look at Key buffer}
  33.   /$9C                        {        PushF}
  34.   /$74/$16                    {        Jz      Fret01          ; Return if no key}
  35.   /$2E                        {        CS:                     ; Test for HOT KEY}
  36.   /$3A/$26/>OUR_HOTKEY        {        Cmp     Ah,[<Our_HotKey]}
  37.   /$75/$0F                    {        Jne     Fret01}
  38.   /$B4/$00                    {        Mov     Ah,0            ; Remove the HotKey}
  39.   /$2E                        {        CS:                     ;  flags are removed by BIOS return}
  40.   /$FF/$1E/>BIOS_INT16        {        Call Dword [>BIOS_INT16]}
  41.   /$2E                        {        CS:                     ; Say we saw the HOT Key}
  42.   /$80/$0E/>STATUS/<HOTKEY_ON {        Or by [<Status],<HotKey_ON}
  43.   /$EB/$E4                    {        Jmp     Func01          ;}
  44.                               {Fret01:}
  45.   /$9D                        {        POPF}
  46.   /$CA/$02/$00                {        RETF    2               ; Return to user}
  47.                               {Func00:}
  48.   /$E8/$1F/$00                {        Call    KeyStat         ; Wait until character available}
  49.   /$74/$FB                    {        Jz      Func00}
  50.   /$B4/$00                    {        Mov     Ah,0            ; Get the next User Key}
  51.   /$9C                        {        PUSHF                   ;}
  52.   /$2E                        {        CS:}
  53.   /$FF/$1E/>BIOS_INT16        {        Call Dword [>BIOS_INT16]}
  54.   /$9C                        {        PushF                   ; Save Return Flags}
  55.   /$2E                        {        CS:}
  56.   /$3A/$26/>OUR_HOTKEY        {        Cmp     Ah,[<Our_HotKey]; Our HotKey ?}
  57.   /$74/$04                    {        Je      GotHotKey       ; yes..enter Staysave code}
  58.   /$9D                        {        POPF                    ; else Restore INT 16 flags}
  59.   /$CA/$02/$00                {        RetF    2               ; Return W/Key discard original INT 16 flags}
  60.                               {                                ; ".. give it to Mikey..he'll eat anything"}
  61.                               {GotHotKey:}
  62.   /$9D                        {        POPF                    ; Discard INT16 return flags}
  63.   /$2E                        {        CS:                     ; Say we saw the HOT Key}
  64.   /$80/$0E/>STATUS/<HOTKEY_ON {        Or by [<Status],<HotKey_ON}
  65.   /$EB/$DE                    {        Jmp  Func00             ; Get another Key}
  66.                               {;}
  67.                               {;       Call the Background task if no key is available}
  68.                               {;}
  69.                               {KeyStat:}
  70.   /$B4/$01                    {        Mov    Ah,01            ; Look for available key}
  71.   /$9C                        {        Pushf                   ; Call the keyboard function}
  72.   /$2E                        {        CS:}
  73.   /$FF/$1E/>BIOS_INT16        {        Call dw [<BIOS_INT16]}
  74.   /$74/$01                    {        Jz      ChkDosCr       ; No Character available from Keyboard}
  75.   /$C3                        {        RET                    ; else return with new flags and code}
  76.                               {ChkDosCr:}
  77.   /$06                        {        Push    ES             ; Check if DOS Critical error in effect}
  78.   /$56                        {        Push    Si}
  79.   /$2E                        {        CS:}
  80.   /$C4/$36/>DOSSTAT2          {        Les     Si,[>DOSStat2]}
  81.   /$26                        {        ES:                     ; Zero says DOS is interruptable}
  82.   /$AC                        {        Lodsb                   ; $FF  says Dos is in a critical state}
  83.   /$2E                        {        CS:}
  84.   /$C4/$36/>DOSSTAT1          {        Les     Si,[>DosStat1]  ; If INDOS then INT $28 issued by DOS}
  85.   /$26                        {        ES:                     ; so we dont have to.}
  86.   /$0A/$04                    {        Or      Al,[SI]}
  87.   /$2E                        {        CS:                     ; Account for active interrupts}
  88.   /$0A/$06/>INTR_FLAGS        {        Or      Al,[<Intr_Flags]; Any flags says we dont issue call}
  89.   /$5E                        {        Pop     Si              ; to the background.}
  90.   /$07                        {        Pop     Es}
  91.   /$3C/$01                    {        Cmp     Al,01           ; Must be INDOS flag only}
  92.   /$7F/$02                    {        JG      Skip28          ; DOS cannot take an interrupt yet}
  93.   /$CD/$28                    {        INT     $28             ; Call Dos Idle function (background dispatch).}
  94.                               {Skip28:}
  95.   /$31/$C0                    {        Xor     Ax,Ax           ; Show  no keycode available}
  96.   /$C3                        {        RET}
  97.                               {;---------------------------------------------------------------------------}
  98. );
  99.